<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户id');
            $table->string('seller_nick')->nullable()->comment('卖家昵称');
            $table->string('pic_path')->default(0)->comment('商品图片路径');
            $table->decimal('payment')->default(0)->comment('交易金额');
            $table->boolean('seller_rate')->default(false)->comment('卖家是否评价');
            $table->decimal('post_fee')->default(0)->comment('邮费');
            $table->string('receiver_name')->nullable()->comment('收货人名称');
            $table->string('receiver_state')->nullable()->comment('收货人省份');
            $table->string('receiver_town')->nullable()->comment('收货人街道地址');
            $table->string('receiver_address')->nullable()->comment('收货人详细地址');
            $table->string('receiver_zip')->nullable()->comment('收货人邮编');
            $table->string('receiver_mobile')->nullable()->comment('收货人手机号');
            $table->string('receiver_phone')->nullable()->comment('收货人电话号');
            $table->string('consign_time')->nullable()->comment('卖家发货时间');
            $table->decimal('received_payment')->default(0)->comment('卖家实际收到的金额');
            $table->string('tid')->nullable()->comment('交易编号');
            $table->integer('num')->nullable()->comment('交易数量');
            $table->string('num_iid')->nullable()->comment('商品数字编号');
            $table->string('status')->nullable()->comment('状态');
            $table->string('title')->nullable()->comment('交易标题');
            $table->string('type')->nullable()->comment('交易类型');
            $table->decimal('price')->default(0)->comment('商品价格');
            $table->decimal('total_fee')->default(0)->comment('商品总金额');
            $table->decimal('discount_fee')->default(0)->comment('商品优惠价格');
            $table->boolean('has_post_fee')->default(false)->comment('是否包邮');
            $table->timestamp('created')->nullable()->comment('订单创建时间');
            $table->timestamp('pay_time')->nullable()->comment('订单支付时间');
            $table->timestamp('modified')->nullable()->comment('交易修改时间');
            $table->timestamp('end_time')->nullable()->comment('交易结束时间');
            $table->string('buyer_message')->nullable()->comment('买家留言');
            $table->string('buyer_memo')->nullable()->comment('买家备注');
            $table->string('buyer_nick')->nullable()->comment('买家昵称');
            $table->string('receiver_city')->nullable()->comment('收件人所在城市');
            $table->string('receiver_district')->nullable()->comment('收件人所在地区');
            $table->timestamp('delivery_time')->nullable()->comment('发货时间');
            $table->timestamp('collect_time')->nullable()->comment('揽收时间');
            $table->timestamp('dispatch_time')->nullable()->comment('派送时间');
            $table->timestamp('sign_time')->nullable()->comment('签收时间');
            $table->string('from_type')->nullable()->comment('会员来源');
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::table('users', function (Blueprint $table) {
            $table->integer('is_member')->default(0)->comment('是否会员')->after('status');
            $table->integer('is_new')->default(0)->comment('是否新会员')->after('status');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
